
#ifndef IQW_GUI_WIDGET_TYPE_H__
#define IQW_GUI_WIDGET_TYPE_H__

#include <stdint.h> 
#include <string.h> 

#include "gui_color.h"
#include "ui_widgets.h"


typedef enum{
    ALIGN_LEFT_TOP,
    ALIGN_LEFT_CENTOR,
    ALIGN_LEFT_BOTTOM,
    ALIGN_MIDDLE_TOP,
    ALIGN_MIDDLE_CENTOR,
    ALIGN_MIDDLE_BOTTOM,
    ALIGN_RIGHT_TOP,
    ALIGN_RIGHT_CENTOR,
    ALIGN_RIGHT_BOTTOM
}ui_widget_align_t;

typedef enum{
    FILL_NONE,
    FILL_BACKCOLOR
}ui_widget_fill_t; 

typedef enum{
    ENCODING_ASCII = 0, 
    ENCODING_UNICODE,
    ENCODING_UTF8, 
}ui_widget_encoding_t;


typedef uint32_t widget_list_type_t;

#define WIDGET_LIST(instance)     static const ui_widgets_type_t *instance[] 
#define WIDGET_ITEM(instance)     (ui_widgets_type_t*)&instance 
#define WIDGET_COUNT(instance)    (sizeof(instance)/sizeof(instance[0])) 
#define WIDGET_LIST_POINTER(instance)     (ui_widgets_type_t*)instance 

typedef struct
{
    int16_t     delta_x;
    int16_t     delta_y;
    int16_t     cs;
    int16_t     ce;
    int16_t     rs;
    int16_t     re;
    uint8_t*   p_dis_buff; 
}widget_paint_opt_t;

typedef struct{
    void (*paint)(  const ui_widgets_t * widget, widget_paint_opt_t *opt);//  int16_t cs, int16_t ce, int16_t rs, int16_t re, uint16_t *p_dis_buff );
    void (*active_update)(  ui_widgets_t * widget, ui_property_t *prop); 
}ui_widget_func_t;



#if defined(__CC_ARM)
    #pragma push
    #pragma anon_unions
#elif defined(__ICCARM__)
    #pragma language=extended
#elif defined(__GNUC__)
    // anonymous unions are enabled by default
#endif
typedef union{
    uint32_t value;
    
    struct{
        char    *data;
        uint16_t len;
    }chars;
    struct{
        uint16_t *unicode;
        uint16_t len;
    }string;
    char data[64];
}ui_widget_data_t; 
#if defined(__CC_ARM)
    #pragma pop
#elif defined(__ICCARM__)
    // leave anonymous unions enabled
#elif defined(__GNUC__)
    // anonymous unions are enabled by default
#endif

//int gui_widget_get_data(ui_widget_data_t * wdd, uint32_t datasrc); 

#endif 

